/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.comunicacion2.model.pathloss;

import com.comunicacion2.model.PathLossModel;

/**
 *
 * @author LangTecnologia
 */
public class FreeSpacePathLoss implements PathLossModel{

    private static final int C = 300;
    
   private final int frequency;
   private final int gainTransmitter;
   private final int gainReciever;
   private final int powerTransmitter;
   
   public FreeSpacePathLoss(int frequency, int gainTransmitter, int gainReciever, int powerTransmitter){
       this.frequency = frequency;
       this.gainTransmitter = gainTransmitter;
       this.gainReciever = gainReciever;
       this.powerTransmitter = powerTransmitter;
   }

    public int calculateIntensity(double distance) {
        
        double intensity = (Math.pow(C/(4 * Math.PI * frequency * distance), 2))* gainTransmitter * gainReciever * powerTransmitter;
        
        Double intensityDb = 10 * Math.log10(intensity);
        
        return intensityDb.intValue();
    }
}
